package com.atgm.mall.gmmallclub.scheduled.schedule;

import com.atgm.mall.gmmallclub.config.QuartzConfig;
import com.atgm.mall.gmmallclub.scheduled.job.ArticleTaskJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName SchedulerListener
 * @Description 定时任务监听器
 * @Auther pdx
 * @Date 2021/11/3 16:08
 * @Verison 1.0
 **/
@Configuration
@EnableScheduling
@Component
public class SchedulerListener {

    @Autowired
    private QuartzConfig quartzConfig;

    @Scheduled(cron = "* * 6 * * ?")
    public void hotArticleScheduler() {
        String name = "hot-article";
        String group = "club";
        quartzConfig.deleteJobs(name, group);
        quartzConfig.addJobs(ArticleTaskJob.class, name, group, "* * 6 * * ?", null);
    }

}
